import {createStore} from 'redux'
import {AnimalItem} from '../types/main'

interface StateInterface{
    list:AnimalItem[]
}

let reducer = (state:StateInterface={list:[]},action:any) => {
    switch (action.type) {
        case 'INIT_DATA':
            //list
            console.log("====action",action.list)
            return {list:[...action.list]}
        case 'ADD_DATA':{
            //target
            return {list:[...state.list,action.target]}
        }
        default:
            return state;
    }
}

let store = createStore(reducer)

export default store